package com.chartboost.sdk.Libraries;

import android.graphics.Bitmap;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public class a
{
  private Map<String, a> a = Collections.synchronizedMap(new LinkedHashMap(10, 1.5F, true));
  private long b = 0L;
  private long c = 1000000L;

  public a()
  {
    a(Runtime.getRuntime().maxMemory() / 4L);
  }

  private static long a(Bitmap paramBitmap)
  {
    if (paramBitmap == null)
      return 0L;
    return paramBitmap.getRowBytes() * paramBitmap.getHeight();
  }

  private void b()
  {
    Iterator localIterator;
    if (this.b > this.c)
      localIterator = this.a.entrySet().iterator();
    do
    {
      if (!localIterator.hasNext())
        return;
      Map.Entry localEntry = (Map.Entry)localIterator.next();
      this.b -= a(((a)localEntry.getValue()).b());
      localIterator.remove();
    }
    while (this.b > this.c);
  }

  public a a(String paramString)
  {
    if (!this.a.containsKey(paramString))
      return null;
    return (a)this.a.get(paramString);
  }

  public void a()
  {
    this.a.clear();
  }

  public void a(long paramLong)
  {
    this.c = paramLong;
  }

  public void a(String paramString, a parama)
  {
    try
    {
      if (this.a.containsKey(paramString))
        this.b -= a(((a)this.a.get(paramString)).b());
      this.a.put(paramString, parama);
      this.b += a(parama.b());
      b();
      return;
    }
    catch (Throwable localThrowable)
    {
      localThrowable.printStackTrace();
    }
  }

  public static class a
  {
    private Bitmap a;
    private int b;
    private boolean c;

    public a(Bitmap paramBitmap, int paramInt)
    {
      a(paramBitmap);
      a(paramInt);
      a(true);
    }

    public void a()
    {
      if (this.c);
      while (true)
      {
        return;
        try
        {
          if ((this.a != null) && (!this.a.isRecycled()))
          {
            this.a.recycle();
            return;
          }
        }
        catch (Exception localException)
        {
        }
      }
    }

    public void a(int paramInt)
    {
      this.b = paramInt;
    }

    public void a(Bitmap paramBitmap)
    {
      this.a = paramBitmap;
    }

    public void a(boolean paramBoolean)
    {
      this.c = paramBoolean;
    }

    public Bitmap b()
    {
      return this.a;
    }

    public int c()
    {
      return this.a.getWidth() * this.b;
    }

    public int d()
    {
      return this.a.getHeight() * this.b;
    }
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.chartboost.sdk.Libraries.a
 * JD-Core Version:    0.6.2
 */